%!PS-Adobe-2.0

% size cm => size

% size mm => size
/unit { } def
/cm { 28.3465 unit mul } def
/mm { cm 10 div } def
/truecm { 28.3465 mul } def
/truemm { truecm 10 div } def

% size name set_font
/set_font {
    findfont
    exch dup 
    /font_height exch def
    scalefont
    setfont
} def

% fontname table oldfont isolatin1
/recode_font {
    findfont
    dup maxlength dict begin
    {
        1 index /FID ne { def } { pop pop } ifelse
    } forall
    /Encoding exch def
    dup /FontName exch def
    currentdict end definefont pop
} bind def

/isotable[ /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef /.notdef /space /exclam /quotedbl
/numbersign /dollar /percent /ampersand /quoteright /parenleft
/parenright /asterisk /plus /comma /hyphen /period /slash /zero /one
/two /three /four /five /six /seven /eight /nine /colon /semicolon
/less /equal /greater /question /at /A /B /C /D /E /F /G /H /I /J /K
/L /M /N /O /P /Q /R /S /T /U /V /W /X /Y /Z /bracketleft /backslash
/bracketright /asciicircum /underscore /quoteleft /a /b /c /d /e /f /g
/h /i /j /k /l /m /n /o /p /q /r /s /t /u /v /w /x /y /z /braceleft
/bar /braceright /asciitilde /.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /dotlessi /grave
/acute /circumflex /tilde /macron /breve /dotaccent /dieresis /.notdef
/ring /cedilla /.notdef /hungarumlaut /ogonek /caron /.notdef
/exclamdown /cent /sterling /currency /yen /brokenbar /section
/dieresis /copyright /ordfeminine /guilsinglleft /logicalnot /hyphen
/registered /macron /degree /plusminus /twosuperior /threesuperior
/acute /mu /paragraph /periodcentered /cedilla /onesuperior
/ordmasculine /guilsinglright /onequarter /onehalf /threequarters
/questiondown /Agrave /Aacute /Acircumflex /Atilde /Adieresis /Aring
/AE /Ccedilla /Egrave /Eacute /Ecircumflex /Edieresis /Igrave /Iacute
/Icircumflex /Idieresis /Eth /Ntilde /Ograve /Oacute /Ocircumflex
/Otilde /Odieresis /multiply /Oslash /Ugrave /Uacute /Ucircumflex
/Udieresis /Yacute /Thorn /germandbls /agrave /aacute /acircumflex
/atilde /adieresis /aring /ae /ccedilla /egrave /eacute /ecircumflex
/edieresis /igrave /iacute /icircumflex /idieresis /eth /ntilde
/ograve /oacute /ocircumflex /otilde /odieresis /divide /oslash
/ugrave /uacute /ucircumflex /udieresis /yacute /thorn /ydieresis ]
def

/charset [
(a) (b) (c) (d) (e) (f) (g) (h) (i) (j) (k) (l) (m) 
(n) (o) (p) (q) (r) (s) (t) (u) (v) (w) (x) (y) (z)
(A) (B) (C) (D) (E) (F) (G) (H) (I) (J) (K) (L) (M) 
(N) (O) (P) (Q) (R) (S) (T) (U) (V) (W) (X) (Y) (Z)
(0) (1) (2) (3) (4) (5) (6) (7) (8) (9) 
(!) (@) (#) ($) (&) (*) (=) (+) (-) (<) (>) (:) (?) (")] def

/rsymbol { rand charset length  mod charset exch get } def
/ralpha  { rand 26 2 mul 10 add mod charset exch get } def
/rdigit  { rand 10 mod 26 2 mul add charset exch get } def

% bind fonts
/Palatino-Bold-ISO  isotable /Palatino-Bold     recode_font
/Palatino-ISO       isotable /Palatino-Roman    recode_font
/Helvetica-ISO      isotable /Helvetica         recode_font
/Helvetica-Bold-ISO isotable /Helvetica-Bold    recode_font

/white  [ 1 1 1 ] def
/black  [ 0 0 0 ] def
/grey1  [ 0.47 0.47 0.47 ] def
/grey2  [ 0.83 0.83 0.83 ] def
/grey3  [ 0.95 0.95 0.95 ] def

/setcolor { aload pop setrgbcolor } def

/box {
    /height exch def
    /width exch def
    gsave
    currentpoint translate
    newpath
    0 0 moveto
    width 0 rlineto
    0 height rlineto
    width neg 0 rlineto
    0 height neg rlineto
    closepath
    fill
    grestore
} def

% str width height box =>
/center_box {
    gsave
    /height exch def
    /width exch def
    /str exch def
    
    currentpoint translate

    width 2 div height 2 div moveto
    str stringwidth
    exch 2 div neg exch
    pop 2.5 unit neg
    rmoveto
    str show
    
    grestore
    width 0 rmoveto   
} def


/charbox { 7.5 unit 11 unit center_box} def
/xbox { 11  unit 11 unit center_box  } def

/border 2 11 unit mul def
/nl {
    currentpoint
    exch pop border exch
    11 unit sub
    moveto
} def

/hskip {
    gsave
    white setcolor
    currentpoint translate
    newpath
    0 0 moveto
    0 11 unit rlineto
    0.7 unit setlinewidth
    stroke
    grestore
    0.7 0 rmoveto
} def
 
/alphabet {
    0 1 25 { 
        dup 
        charset exch get charbox
        1 add 3 mod 0 eq { hskip } if
    } for
} def

/letters {
    0 1 25 {
        exch dup cvx exec charbox exch
        1 add 3 mod 0 eq { hskip } if
    } for    
    pop
} def

/cardwidth 240 def
/overshoot 10  def
/cardwidth cardwidth overshoot add def

/card {
    gsave
    currentpoint translate

    % rand 2 mod 0 eq { grey3 setcolor 85 mm 55 mm box } if

    1 11 unit mul  12 11 unit mul moveto
    0 unit 0 unit neg rmoveto 
    /Palatino-Bold-ISO findfont 18 unit scalefont setfont
    grey1 setcolor
    (Vistabella) show

    2 11 unit mul 10 11 unit mul moveto
    grey1 setcolor
    cardwidth unit 2 11 unit mul sub 11 unit box
    2 11 unit mul 10 11 unit mul moveto
    2 unit 2 unit rmoveto
    /Palatino-Bold-ISO findfont 9 unit scalefont setfont
    white setcolor
    (Password) show
    
    
    2 11 unit mul 9 11 unit mul moveto
    grey2 setcolor cardwidth unit 2 11 unit mul sub 11 unit box 
    2 11 unit mul 7 11 unit mul moveto
    grey3 setcolor cardwidth unit 2 11 unit mul sub 22 unit box
    2 11 unit mul 6 11 unit mul moveto
    grey2 setcolor cardwidth unit 2 11 unit mul sub 11 unit box
    2 11 unit mul 4 11 unit mul moveto
    grey3 setcolor cardwidth unit 2 11 unit mul sub 22 unit box
    2 11 unit mul 3 11 unit mul moveto
    grey2 setcolor cardwidth unit 2 11 unit mul sub 11 unit box
    2 11 unit mul 1 11 unit mul moveto
    grey3 setcolor cardwidth unit 2 11 unit mul sub 22 unit box
     
    2 11 unit mul 9 11 unit mul moveto
    /Helvetica-Bold-ISO findfont 8 unit scalefont setfont
    ()  xbox hskip black setcolor alphabet nl
    /Helvetica-Bold-ISO findfont 8 unit scalefont setfont (1) xbox hskip 
    /Palatino-ISO findfont 8 unit scalefont setfont /rsymbol letters nl
    /Helvetica-Bold-ISO findfont 8 unit scalefont setfont (2) xbox hskip 
    /Palatino-ISO findfont 8 unit scalefont setfont /rsymbol letters nl
     
    /Helvetica-Bold-ISO findfont 8 unit scalefont setfont
    ()  xbox hskip black setcolor alphabet nl
    /Helvetica-Bold-ISO findfont 8 unit scalefont setfont (3) xbox hskip 
    /Palatino-ISO findfont 8 unit scalefont setfont /ralpha letters nl
    /Helvetica-Bold-ISO findfont 8 unit scalefont setfont (4) xbox hskip 
    /Palatino-ISO findfont 8 unit scalefont setfont /ralpha letters nl
    
    /Helvetica-Bold-ISO findfont 8 unit scalefont setfont
    ()  xbox hskip black setcolor alphabet nl
    /Helvetica-Bold-ISO findfont 8 unit scalefont setfont (5) xbox hskip 
    /Palatino-ISO findfont 8 unit scalefont setfont /rdigit letters nl
    /Helvetica-Bold-ISO findfont 8 unit scalefont setfont (6) xbox hskip 
    /Palatino-ISO findfont 8 unit scalefont setfont /rdigit letters nl
    
    grestore
} def

false
{    
    newpath
    15 truemm 12 truemm moveto
    85 truemm 10 truemm add 85 truemm add 0 truemm rlineto
    0  truemm 55 truemm 5 mul rlineto
    85 truemm 10 truemm add 85 truemm add neg 0 truemm rlineto
    closepath
    black setcolor 1 setlinewidth
    stroke

    newpath
    15 truemm 85 truemm add 12 truemm moveto
    0 55 truemm 5 mul rlineto
    stroke
    newpath
    15 truemm 85 truemm add 10 truemm add 12 truemm moveto
    0 55 truemm 5 mul rlineto
    stroke
} if


rrand
0 1 4 {
    55 mm mul 12 truemm add 
    15 truemm exch moveto card
} for
srand
0 1 4 {
    55 mm mul 12 truemm add 
    110 mm exch moveto card
} for
showpage
